package com.zhang.sequencegenerate.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhang.sequencegenerate.entity.SequenceRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * @Description
 * @Author Mr.Zhang
 * @Date 2025/5/25 21:03
 * @Version 1.0
 */
@Mapper
public interface SequenceRecordMapper extends BaseMapper<SequenceRecord> {

    @Update("UPDATE sequence_record SET sequence_value = #{newValue} WHERE sequence_key = #{sequenceKey} AND sequence_key = #{oldValue}")
    int nextValue(@Param(value = "newValue") long newValue, @Param(value = "oldValue") Long oldValue, @Param(value = "sequenceKey") String sequenceKey);
}
